4/26/2017

Monthly precipitation

library(ggplot2)
climate <- read.table("clim.txt", header=T)
climate$date <- NULL
clim_month <- aggregate(rain~year+month, data = climate, FUN = sum)
ggplot(clim_month, aes(group=month, x = month, y = rain)) +
  geom_boxplot(fill = "cyan") +
  scale_y_continuous(name = "Total Monthly Precipitation") +
  theme_bw()+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
  scale_x_continuous(name = "Month", breaks = c(1,2,3,4,5,6,7,8,9,10,11,12))

Figure 1. Boxplot of average monthly precipitation based on data from years 1942-2016.

Monthly temperatures

clim_temp_min <- aggregate(tmin~month+year, data = climate, FUN = mean)
clim_temp_max <- aggregate(tmax~month+year, data = climate, FUN = mean)
clim_temp <- merge(clim_temp_max, clim_temp_min)

ggplot(clim_temp, aes(group= month, x = month)) +
  geom_boxplot(aes(y=tmax), fill = "orange") +
  geom_boxplot(aes(y=tmin), fill = "lightskyblue1") +
  scale_y_continuous(name = "Average Min and Max Temperatures (C)") +
  theme_bw()+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
  scale_x_continuous(name = "Month", breaks = c(1,2,3,4,5,6,7,8,9,10,11,12))

Figure 2. Shows average monthly temperatures (°C), where average highs are shown in orange, and lows shown in blue.

Calculating wet and dry years

clim_rain <- aggregate(rain~year, data = climate, FUN = sum)
ggplot(clim_rain, aes(y = rain, x = year))+
  geom_line(stat = "identity", color = "blue", size = 0.5) +
  theme_bw()+
  scale_x_continuous(breaks=seq(1940, 2020, by = 5))+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
  ylab("Total Annual Precipitation")+
  xlab("Year")

Figure 3.Time series of annual precipitation spanning from 1942-2016
Based on the above, the wettest years were 1982, 1969, 1983, and 1996. The driest years were 2013, 1947, 2016, and 1976.

Wet and dry years along the California Coast: Big Sur, California

Wet and dry seasons

range(climate$month)
## [1]  1 12
climate$season = ifelse(climate$month %in% c(3,4,5),"1", ifelse(climate$month%in% c(6,7,8),"2", ifelse(climate$month %in% c(9,10,11),"3", "4")))
clim_season <- aggregate(rain~season+month+year, data = climate, FUN = sum)
ggplot(clim_season, aes(group=season, x = season, y = rain)) +
  geom_boxplot(fill = "cyan") +
  scale_y_continuous(name = "Precipitation") +
  theme_bw()+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
  scale_x_discrete(name = "Season")

Figure 4. Seasonal precipitation where 1 represents spring, 2 summer, 3 fall, and 4 winter. Spring is months March-May, summer months June-August, fall months September-November, and winter months December-February.

Winter Precipitation and Summer Temperature

seasonal_rain <- aggregate(rain~year+season, data = climate, FUN = sum)
winter_rain<- subset(seasonal_rain, season == 4)
season_temp <- aggregate(tmax~year+season, data = climate, FUN = mean)
summer_temp <- subset(season_temp, season == 2)
rain_temp <- merge(summer_temp, winter_rain, by = "year")
ggplot(rain_temp, aes(x=rain, y= tmax, group_by(year))) +
  geom_point(size=0.8)+
  geom_smooth(method=lm, se = FALSE, formula = y ~ x, color = "blue", size = 0.5)+
  theme_bw()+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
  xlab("Total Winter Precipitation")+
  ylab("Mean Temperature")

Plot showing relationship between winter precipitation and summer temperature

linear_reg <-lm(rain ~ tmax, data=rain_temp)
summary(linear_reg)
## 
## Call:
## lm(formula = rain ~ tmax, data = rain_temp)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -402.56 -167.86  -51.86  156.82 1019.19 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)   986.37     560.93   1.758   0.0829 .
## tmax          -20.48      24.67  -0.830   0.4091  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 263.1 on 73 degrees of freedom
## Multiple R-squared:  0.009355,   Adjusted R-squared:  -0.004216 
## F-statistic: 0.6894 on 1 and 73 DF,  p-value: 0.4091
The relationship between winter precipitation and summer temperature might be useful to know because while the above relationship is not significant there is a slightly negative relationship between winter precipitation and summer temperatures. This may be important particularly in dry years, as warmer temperatures and dry conditions may lead to a significant fire season.